package com.hwhhhh.mygrad;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.hwhhhh.mygrad.dto.UserDTO;
import com.hwhhhh.mygrad.utils.StringUtils;

public class SettingNewActivity extends BaseActivity implements View.OnClickListener{
    private ConstraintLayout adminLayout;   // 管理员功能
    private ConstraintLayout userLayout;    // 用户资料
    private TextView tvLogout;  // 退出登录
    private View dividerAdmin;
    private UserDTO userDTO;

    @Override
    protected void initView() {
        adminLayout = findViewById(R.id.setting_admin);
        userLayout = findViewById(R.id.setting_user_info);
        tvLogout = findViewById(R.id.tv_logout);
        dividerAdmin = findViewById(R.id.divider_admin);
    }

    @Override
    protected int initLayout() {
        return R.layout.activity_new_setting;
    }

    @Override
    protected void initData() {
        userLayout.setOnClickListener(this);
        userDTO = getUser();
        if (userDTO.getIsAd() == 1) {
            adminLayout.setVisibility(View.VISIBLE);
            dividerAdmin.setVisibility(View.VISIBLE);
            adminLayout.setOnClickListener(this);
        }
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.setting_user_info) { // 用户资料
            navigateTo(UserInfoActivity.class);
        } else if (id == R.id.setting_admin){   // 管理员功能
            navigateTo(AdminActivity.class);
        }
    }
}